package com.mjf.thread;

/**
 * 创建线程的4中方式：
 * 1.继承Thread类
 * 2.实现Runnable接口
 * 3.实现Callable接口(重写call方法)
 * 4.线程池
  */
public class CreateThreadWithThread {

    public static void main(String[] args) {

        Thread t1 = new Thread(new OddNumber());
        Thread t2 = new Thread(new EvenNumber());
        t1.start();
        t2.start();
    }
}

// 奇数
class OddNumber implements Runnable{

    public void run() {
        for (int i = 1; i < 101; i++) {
            if (i%2 == 1) {
                System.out.println("奇数：" + i);
            }
        }
    }
}

// 偶数
class EvenNumber implements Runnable{

    public void run() {
        for (int i = 1; i < 101; i++) {
            if (i%2 == 0) {
                System.out.println("偶数：" + i);
            }
        }
    }
}